package com.itheima.mybatis.web;

import com.itheima.mybatis.pojo.Address;
import com.itheima.mybatis.pojo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
public class ResponseController {
    /**
     * 相应普通字符串
     * @return
     */
    @RequestMapping("/helloworld")
    public Result hello(){
        return Result.error("服务器处理失败");
    }
    /**
     * 相应实体对象
     * @return
     */
    @RequestMapping("/getAddr")
    public Result getAddr(){
        Address address = new Address();
        address.setCity("河北");
        address.setProvince("邢台");
        return Result.success(address);
    }
    /**
     * 响应集合数据
     * @return
     */
    @RequestMapping("/listAddr")
    public Result listAddr(){
        ArrayList<Address> list = new ArrayList<>();
        Address address = new Address();
        address.setCity("河北");
        address.setProvince("邢台");
        Address address1 = new Address();
        address.setCity("南京");
        address.setProvince("安徽");
        list.add(address);
        list.add(address1);
        return Result.success(list);
    }
}
